package com.nh.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;

/**
 * 信息内容基类
 * 
 * @author lxj
 * 
 */
@MappedSuperclass
public class BaseInfoEntity extends BaseEntity {
	private String imagelistString;
	private List<ImageVO> imageInfoList;

	@Column(columnDefinition = "TEXT")
	public String getImagelistString() {
		return imagelistString;
	}

	public void setImagelistString(String imagelistString) {
		this.imagelistString = imagelistString;
	}

	@Transient
	public List<ImageVO> getImageInfoList() {
		imageInfoList = new ArrayList<ImageVO>();
		if (StringUtils.isNotEmpty(imagelistString)) {
			if (imagelistString.contains(",")) {
				String[] imageUrls = imagelistString.split(",");
				for (String url : imageUrls) {
					if (StringUtils.isEmpty(url)) {
						continue;
					} else {
						// 过滤运程图片
						if (!url.startsWith("http:")) {
							imageInfoList.add(new ImageVO(url));
						}

					}
				}

			}

		}
		return imageInfoList;
	}

	public void setImageInfoList(List<ImageVO> imageInfoList) {
		this.imageInfoList = imageInfoList;
	}

}
